﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import org.aswing.util.*;

    public class VectorListModel extends AbstractListModel implements MutableListModel, List {

        public static const CASEINSENSITIVE:int = 1;
        public static const DESCENDING:int = 2;
        public static const UNIQUESORT:int = 4;
        public static const RETURNINDEXEDARRAY:int = 8;
        public static const NUMERIC:int = 16;

        protected var _elements:Array;

        public function VectorListModel(_arg1:Array=null){
            if (_arg1 != null){
                this._elements = _arg1.concat();
            } else {
                this._elements = new Array();
            };
        }
        public function get(_arg1:int){
            return (this._elements[_arg1]);
        }
        public function getElementAt(_arg1:int){
            return (this._elements[_arg1]);
        }
        public function append(_arg1, _arg2:int=-1):void{
            if (_arg2 == -1){
                _arg2 = this._elements.length;
                this._elements.push(_arg1);
            } else {
                this._elements.splice(_arg2, 0, _arg1);
            };
            fireIntervalAdded(this, _arg2, _arg2);
        }
        public function replaceAt(_arg1:int, _arg2){
            if ((((_arg1 < 0)) || ((_arg1 >= this.size())))){
                return (null);
            };
            var _local3:* = this._elements[_arg1];
            this._elements[_arg1] = _arg2;
            fireContentsChanged(this, _arg1, _arg1, [_local3]);
            return (_local3);
        }
        public function appendAll(_arg1:Array, _arg2:int=-1):void{
            var _local3:Array;
            if ((((_arg1 == null)) || ((_arg1.length <= 0)))){
                return;
            };
            if (_arg2 == -1){
                _arg2 = this._elements.length;
            };
            if (_arg2 == 0){
                this._elements = _arg1.concat(this._elements);
            } else {
                if (_arg2 == this._elements.length){
                    this._elements = this._elements.concat(_arg1);
                } else {
                    _local3 = this._elements.splice(_arg2);
                    this._elements = this._elements.concat(_arg1);
                    this._elements = this._elements.concat(_local3);
                };
            };
            fireIntervalAdded(this, _arg2, ((_arg2 + _arg1.length) - 1));
        }
        public function valueChanged(_arg1):void{
            this.valueChangedAt(this.indexOf(_arg1));
        }
        public function valueChangedAt(_arg1:int):void{
            if ((((_arg1 >= 0)) && ((_arg1 < this._elements.length)))){
                fireContentsChanged(this, _arg1, _arg1, []);
            };
        }
        public function valueChangedRange(_arg1:int, _arg2:int):void{
            fireContentsChanged(this, _arg1, _arg2, []);
        }
        public function removeAt(_arg1:int){
            if ((((_arg1 < 0)) || ((_arg1 >= this.size())))){
                return (null);
            };
            var _local2:* = this._elements[_arg1];
            this._elements.splice(_arg1, 1);
            fireIntervalRemoved(this, _arg1, _arg1, [_local2]);
            return (_local2);
        }
        public function remove(_arg1){
            var _local2:int = this.indexOf(_arg1);
            if (_local2 >= 0){
                return (this.removeAt(_local2));
            };
            return (null);
        }
        public function removeRange(_arg1:int, _arg2:int):Array{
            var _local3:Array;
            if (this._elements.length > 0){
                _arg1 = Math.max(0, _arg1);
                _arg2 = Math.min(_arg2, (this._elements.length - 1));
                if (_arg1 > _arg2){
                    return ([]);
                };
                _local3 = this._elements.splice(_arg1, ((_arg2 - _arg1) + 1));
                fireIntervalRemoved(this, _arg1, _arg2, _local3);
                return (_local3);
            };
            return ([]);
        }
        public function removeElementAt(_arg1:int):void{
            this.removeAt(_arg1);
        }
        public function insertElementAt(_arg1, _arg2:int):void{
            this.append(_arg1, _arg2);
        }
        public function indexOf(_arg1):int{
            var _local2:int;
            while (_local2 < this._elements.length) {
                if (this._elements[_local2] == _arg1){
                    return (_local2);
                };
                _local2++;
            };
            return (-1);
        }
        public function contains(_arg1):Boolean{
            return ((this.indexOf(_arg1) >= 0));
        }
        public function appendList(_arg1:List, _arg2:int=-1):void{
            this.appendAll(_arg1.toArray(), _arg2);
        }
        public function pop(){
            if (this.size() > 0){
                return (this.removeAt((this.size() - 1)));
            };
            return (null);
        }
        public function shift(){
            if (this.size() > 0){
                return (this.removeAt(0));
            };
            return (null);
        }
        public function first(){
            return (this._elements[0]);
        }
        public function last(){
            return (this._elements[(this._elements.length - 1)]);
        }
        public function size():int{
            return (this._elements.length);
        }
        public function isEmpty():Boolean{
            return ((this._elements.length <= 0));
        }
        public function getSize():int{
            return (this.size());
        }
        public function clear():void{
            var _local2:Array;
            var _local1:int = (this.size() - 1);
            if (_local1 >= 0){
                _local2 = this.toArray();
                this._elements.splice(0);
                fireIntervalRemoved(this, 0, _local1, _local2);
            };
        }
        public function toArray():Array{
            return (this._elements.concat());
        }
        public function subArray(_arg1:int, _arg2:int):Array{
            if ((((this.size() == 0)) || ((_arg2 <= 0)))){
                return (new Array());
            };
            return (this._elements.slice(_arg1, Math.min((_arg1 + _arg2), this.size())));
        }
        public function sort(_arg1:Object, _arg2:int):Array{
            var _local3:Array = this._elements.sort(_arg1, _arg2);
            fireContentsChanged(this, 0, (this._elements.length - 1), []);
            return (_local3);
        }
        public function sortOn(_arg1:Object, _arg2:int):Array{
            var _local3:Array = this._elements.sortOn(_arg1, _arg2);
            fireContentsChanged(this, 0, (this._elements.length - 1), []);
            return (_local3);
        }
        public function toString():String{
            return (("VectorListModel : " + this._elements.toString()));
        }

    }
}//package org.aswing 
